package com.ad.pet.app.main.desniger;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.ad.pet.MainActivityCompent;
import com.ad.pet.R;
import com.ad.pet.app.Navigation;
import com.ad.pet.app.main.desniger.adapter.DesnigerColumnAdapter;
import com.ad.pet.common.structure.mvp.BasePresenter;
import com.ad.pet.common.structure.ui.fragment.LoadingFragment;
import com.ad.pet.models.remote.main.DesingerMain;
import com.ad.pet.models.remote.main.DesingerType;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;

/**
 * Created by SEELE on 2019/6/26.
 */

public class DesnigerFragment extends LoadingFragment implements DesnigerContract.View {
    @BindView(R.id.recycler_home)
    RecyclerView mRecyclerHome;
//    @BindView(R.id.swipeRefresh)
//    SwipeRefreshLayout mSwipeRefresh;
    String id;


    @Inject
    DesnigerPresenter mDesnigerPresenter;
    private DesnigerColumnAdapter mDesnigerColumnAdapter;
    private String shopId;

    @Override
    protected int contentLayout() {
        return R.layout.fragment_desniger;
    }

    @Override
    protected void clickRetry(View v) {

    }

    @Override
    protected void initData() {
        mRecyclerHome.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL,false));
        mDesnigerColumnAdapter = new DesnigerColumnAdapter(null);
        mRecyclerHome.setAdapter(mDesnigerColumnAdapter);
        id = getArguments().getString("id");
        shopId = getArguments().getString("shopId");


        mDesnigerPresenter.getShopService(id);
        mStatusLayoutManager.showContent();
    }

    @Override
    protected void initEvents() {


        mDesnigerColumnAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Navigation.goServiceDetail(getActivity(),mDesnigerColumnAdapter.getData().get(position).getOffservice_id(),shopId,getArguments().getString("shop_name"));
            }
        });


    }

    @Override
    protected void initViews() {

        mDesnigerPresenter.onCreate(this);




    }

    @Override
    public void initInjector() {
        getComponent(MainActivityCompent.class).inject(this);
    }

    @Override
    protected BasePresenter getPresenter() {
        return mDesnigerPresenter;
    }


    public static DesnigerFragment newInstance(String id,String shopId,String shop_name) {

        DesnigerFragment fragment = new DesnigerFragment();
        Bundle bundle = new Bundle();
        bundle.putString("id",id);
        bundle.putString("shopId",shopId);
        bundle.putString("shop_name",shop_name);
        fragment.setArguments(bundle);

        return fragment;
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void error(String msg) {

    }

    @Override
    public void error(int code, String msg) {


    }

    @Override
    public void getDesginerShopSuccess(List<DesingerMain> store) {

    }

    @Override
    public void getShopServiceSuccess(List<DesingerType> shopServices) {
        mDesnigerColumnAdapter.setNewData(shopServices);
    }

    @Override
    public void getStoreDetailSuccess(DesingerMain desingerMain) {

    }


}
